package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.entity.TitleValueEntity;
import cn.limc.ohoscharts.view.SpiderWebChart;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;

import java.util.ArrayList;
import java.util.List;

public class SpiderWebChartAbility extends AbilitySlice {

  SpiderWebChart spiderwebchart;

  @Override
  public void onStart(Intent intent) {
    super.onStart(intent);
    super.setUIContent(ResourceTable.Layout_ability_spider_web_chart);
    initSpiderWebChart();
  }

  private void initSpiderWebChart() {
    this.spiderwebchart = (SpiderWebChart) findComponentById(ResourceTable.Id_spiderwebchart);

    List<TitleValueEntity> data1 = new ArrayList<TitleValueEntity>();
    data1.add(new TitleValueEntity("Alpha", 3));
    data1.add(new TitleValueEntity("Bravo", 4));
    data1.add(new TitleValueEntity("Charlie", 9));
    data1.add(new TitleValueEntity("Delta", 8));
    data1.add(new TitleValueEntity("Echo", 10));

    List<TitleValueEntity> data2 = new ArrayList<TitleValueEntity>();
    data2.add(new TitleValueEntity("Echo", 3));
    data2.add(new TitleValueEntity("Echo", 4));
    data2.add(new TitleValueEntity("Echo", 5));
    data2.add(new TitleValueEntity("Echo", 6));
    data2.add(new TitleValueEntity("Echo", 7));

    List<List<TitleValueEntity>> data = new ArrayList<List<TitleValueEntity>>();
    data.add(data1);
    data.add(data2);

    spiderwebchart.setData(data);
    spiderwebchart.setLatitudeNum(5);
  }
}
